all:      olcdtool

GLOBAL_DEP  = adprog.h lpc21isp.h lpcprog.h lpcterm.h serialio.h platform.h
CC = gcc

ifneq ($(findstring(freebsd, $(OSTYPE))),)
CFLAGS+=-D__FREEBSD__
endif

ifeq ($(OSTYPE),)
OSTYPE		= $(shell uname)
endif

ifneq ($(findstring Darwin,$(OSTYPE)),)
CFLAGS+=-D__APPLE__
endif

CFLAGS	+= -Wall

adprog.o: adprog.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o adprog.o adprog.c

lpcprog.o: lpcprog.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o lpcprog.o lpcprog.c

lpcterm.o: lpcterm.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o lpcterm.o lpcterm.c

serialio.o: serialio.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o serialio.o serialio.c

olcd.o: olcd.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o olcd.o olcd.c
	
platform.o: platform.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o platform.o platform.c

olcddemo.o: olcddemo.c $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -c -o olcddemo.o olcddemo.c

olcdtool: lpc21isp.c adprog.o lpcprog.o lpcterm.o serialio.o olcd.o platform.o olcddemo.o $(GLOBAL_DEP)
	$(CC) $(CDEBUG) $(CFLAGS) -o olcdtool lpc21isp.c adprog.o lpcprog.o lpcterm.o serialio.o olcd.o platform.o olcddemo.o

clean:
	$(RM) adprog.o lpcprog.o lpcterm.o serialio.o olcd.o platform.o olcddemo.o olcdtool
